<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'home';
cfc('core')->checklogin('jy_kefu/chat//getmid='.$_RQ['getmid']);
$return=array();
if($_RQ['op']=='home'){
	if($_SESSION['os']=='windows' && !$_RQ['get']){
		exi('','','/mychat//getmid='.$_RQ['getmid']);
	}
	$return['set']= pdo_get('jy_kefu_set',array('uniacid'=>$_SESSION['uniacid']));

	if(!empty($_SESSION['openid'])){
		$openid = $_SESSION['openid'];
		$fansfollow=pdo_getcolumn('core_fans',array('uniacid'=>$_SESSION['uniacid'],'openid'=>$_SESSION['openid']),'follow');
	}
	$member = pdo_get('jy_kefu_member',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_SESSION['uid']));
	if(!empty($member['isblack'])){
		exi('您暂时不能咨询！','error','/home/');
	}
	$getmid = trim($_RQ['getmid']);
	$kfid = trim($_RQ['kfid']);
	$setmid = $_SESSION['uid'];
	if($setmid == $getmid){
		exi('亲！不能和自己聊天哦！','error','/home/');
	}
	if(empty($member)){
		$member = $this->model('kefu')->upmember($setmid,$openid);
	}else{
		$member=pdo_get('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),array('avatar','nickname'));
		$member['logo']=$member['avatar'];
		$member['name']=$member['nickname'];
	}
	if($getmid){
		$return['url']=custom_url('/chat//getmid='.$getmid,true);
		$getmember = $this->model('kefu')->getmember($getmid);
		$fansauto = empty($kefu['fansauto']) ? '' : explode("|",$kefu['fansauto']);
		$setting=core_setting('cloud');
		$return['sign']=sha1(TIMESTAMP.$setting['cloudkey'].$_SESSION['uniacid'].$_SESSION['uid'].$setting['secret']);
		$from_id = $_SESSION['uid'];
		$to_id = $getmid;
		//心跳，to_id = 0
		$return['sockettcp']=$return['sign'].';'.TIMESTAMP.';'.$setting['cloudkey'].';'.$_SESSION['uniacid'].';'.$from_id.';0';
		//数据串
		$return['socketdata']=$return['sign'].';'.TIMESTAMP.';'.$setting['cloudkey'].';'.$_SESSION['uniacid'].';'.$from_id.';'.$to_id;
	}else{
		$return['url']=custom_url('/chat//getmid='.$kfid,true);
		$kfname = pdo_getcolumn('jy_kefus',array('id'=>$kfid),'nickname');
		$getmember['name'] = $kfname?$kfname:'机器人';
	}
	$getmid = $getmid?$getmid:888888888;
	if($_RQ['chatid']){
		$chatid = intval($_RQ['chatid']);
	}else{
		$chatid = $this->model('kefu')->getchatid($setmid,$getmid);
	}
	$nowchat= pdo_get('jy_kefu_member_chat',array('uniacid'=>$_SESSION['uniacid'],'msgtype >'=>0,'mid'=>$_SESSION['uid'],'getmid'=>$getmid));
	$kefuinfo=pdo_get('jy_kefus',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$getmid),array('mid','welcometext','fansauto','kefuauto','autoset'));
	if((!$nowchat['lasttime'] || $nowchat['lasttime']+3600*3<time()) && $kefuinfo['welcometext']){
		$addlog=$this->model('kefu')->addchatlog($kefuinfo['welcometext'],$chatid,$_SESSION['uid'],1,'',$getmid);
		$return['welcomelogid']=$addlog['id'];
	}
	if($kefuinfo['mid']){
		$kefuinfo['fansauto']=nl2br($kefuinfo['fansauto']);
		$return['fastmsg']=explode('<br />',$kefuinfo['fansauto']);
	}else{
		$mekefu=pdo_get('jy_kefus',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),array('mid','welcometext','fansauto','kefuauto','autoset'));
		if($mekefu['mid']){
			$kefuinfo['kefuauto']=nl2br($kefuinfo['kefuauto']);
			$return['fastmsg']=explode('<br />',$kefuinfo['kefuauto']);
			$return['myiskefu']= 1;
		}
	}
	$member['logo']=$member['logo']?tomedia($member['logo']):'../core/resource/images/noavatar.gif';
	$getmember['logo']=$getmember['logo']?tomedia($getmember['logo']):'../core/resource/images/gw-wx.png';
	$this->session('getmemberlogo',$getmember['logo']);
	$this->session('memberlogo',$member['logo']);
	$return['url']=custom_url('/chat//chatid='.$chatid,true);
	$return['account']=$_SESSION['account'];
	$return['fansfollow']= $fansfollow;
	$return['chatid']= $chatid;
	$return['getmid']= $getmid;
	$return['openid']= $_SESSION['openid'];
	$return['getmember']= $getmember;
	$return['member']= $member;
	$return['chatlog']= array();
	set_html('title','和'.$getmember['name'].'的对话');
	exi($return);
}
if($_RQ['op']=='list'){
	$chatid = intval($_RQ['chatid']);
	$getmemberlogo=$this->session('getmemberlogo');
	$memberlogo=$this->session('memberlogo');
	if(empty($chatid)){
		$return['error'] = 1;
		$return['msg'] = '没有获取到会话！'.$chatid;
		exi($return);
	}
	$params=array('uniacid'=>$_SESSION['uniacid'],'chatid'=>$chatid);
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total = 0;
	$chatlog=pdo_getslice('jy_kefu_chatlog',$params,array($pindex,$psize),$total,$fields,'','id DESC');
	$timestamp = TIMESTAMP;
	$setting=pdo_get('jy_kefu_set',array('uniacid'=>$_SESSION['uniacid']),array('title','isremind','sharetitle','sharedes','sharepicurl','kefuremindtime','bgcolor','nologo','isautomsg','autotype','isunfollow','filterword','confcolor','groupremind','groupremindtime','groupshowindex','showgroupnum','jyrobotkey','isjyrobot'));
	$chatlogtime = time();
	if($chatlog){
		foreach($chatlog as $k=>&$v){
					$settime = $v['createtime'];
					if(($chatlogtime - $v['createtime']) > 600 || $k+1==count($chatlog)){
						$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
					}else{
						$v['createtime'] = '';
					}
					$chatlogtime = $settime;
					$v['msg'] = cfc('tools')->filterword($v['msg'],$setting['filterword']);
					$v['msg'] = preg_replace('/\xEE[\x80-\xBF][\x80-\xBF]|\xEF[\x81-\x83][\x80-\xBF]/', '[无法识别字符]', $v['msg']);
					$hrefhtml = '@(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))@';
					preg_match_all($hrefhtml,$v['msg'],$resarray);  
					if($v['type'] == 1 || $v['type'] == 2){
						foreach($resarray[0] as &$vv){
							if(!empty($vv)){
								$v['msg'] = str_replace($vv,"<a href='".$vv."'>".$vv."</a>",$v['msg']);
							}
						}
						if($v['getmid'] == $_SESSION['uid']){
							pdo_update('jy_kefu_chatlog',array('isread'=>1),array('id'=>$v['id'],'uniacid'=>$_SESSION['uniacid']));
						}
					}
					if($v['type'] == 3){
						$v['audioleng'] = $v['audiotime'] >2 ? $v['audiotime']:'2';
					}
					if($v['type'] == 4){
						if($v['getmid'] == $_SESSION['uid']){
							pdo_update('jy_kefu_chatlog',array('isread'=>1),array('id'=>$v['id'],'uniacid'=>$_SESSION['uniacid']));
						}
					}
		}
		$html = '';
		if($_SESSION['os']=='windows'){
			sort($chatlog);
		}
		foreach($chatlog as &$v){
			if($_SESSION['os']=='windows'){
				$htmltime = '<div class="message_box_time">'.$v['createtime'].'</div>';
				if($v['type'] == 1){
						$html .= $htmltime;
						if($v['setmid'] != $_SESSION['uid']){
							$html .='<div class="message_box"><img class="mssage_box_pic" src="'.$getmemberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><p>'.$v['msg'].'</p></div></div></div>';
						}else{
							$html .='<div class="message_box from_self"><img class="mssage_box_pic" src="'.$memberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><p>'.$v['msg'].'</p></div></div></div>';
						}
						
				}elseif($v['type'] == 3){
					$html .= $htmltime;
					//$v['msg']=tomedia($v['msg']);
					if($v['setmid'] != $_SESSION['uid']){
							$playhtml = '<span ng-show="pagedata.playon == 1" ng-click="pagedata.playon =0" style="display:none;width:'.$v['audioleng'].'rem;text-align:right" class="text kefu-playon"><img src="../core/resource/images/audioplaying.gif"/></span><span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$v['audioleng'].'rem;text-align:right" class="text icon jinyunicon icon-shengbo"></span>';
							$html .='<div onclick="playaudio(\''.$v['msg'].'\');" class="r clearfix"><img class="pic"/><span>'.$v['audiotime'].'\'\'</span>'.$playhtml.'</div>';
					}else{
							if($v['isread'] != 1){
								$unread = '<span class="unread"></span>';
							}else{
								$unread ='';
							}
							$playhtml = '<span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$v['audioleng'].'rem" class="text icon jinyunicon icon-shengbo"></span>';
							$html .='<div onclick="playaudio(\''.$v['msg'].'\',\'\','.$v['id'].');" class="l clearfix"><img class="pic"/>'.$playhtml.'<span>'.$v['audiotime'].'\'\'</span>'.$unread.'</div>';
					}
					
				}elseif($v['type'] == 4){
					$v['msg']=tomedia($v['msg']);
						if($v['setmid'] != $_SESSION['uid']){
							$html .='<div class="message_box"><img class="mssage_box_pic" src="'.$getmemberlogo.'" style="display:inline-block;"/><div class="message_content"><p onclick="followewm(\''.$v['msg'].'\');" class="message_content_inner media"><img src="'.$v['msg'].'" style="width:100%;"/></p></div></div>';
						}else{
							$html .='<div class="message_box from_self"><img class="mssage_box_pic" src="'.$memberlogo.'" style="display:inline-block;"/><div class="message_content"><p onclick="followewm(\''.$v['msg'].'\');" class="message_content_inner media"><img src="'.$v['msg'].'" style="width:100%;"/></p></div></div>';
						}
				}elseif($v['type'] == 7){
					$fileurl=tomedia($v['msg']);
					$pathinfo=pathinfo($v['msg']);
					$fileicon=$pathinfo[extension];
					$filename=pdo_getcolumn('core_attachment',array('uniacid'=>$_SESSION['uniacid'],'attachment'=>$v['msg']),'title');
					$filename=$filename.'.'.$pathinfo[extension];
					if(strpos($fileicon,'xls')){
						$fileicon='icon-exl';
					}elseif(strpos($fileicon,'pd')){
						$fileicon='icon-pdf';
					}elseif(strpos($fileicon,'do')){
						$fileicon='icon-exl';
					}elseif(strpos($fileicon,'zip') || strpos($fileicon,'rar')){
						$fileicon='icon-zip';
					}else{
						$fileicon='icon-copy';
					}
					$filesize=filesize(ROOT_AT.'/'.$v['msg'])/1000;
					$filesize=$filesize.'kb';
					if($v['setmid'] != $_SESSION['uid']){
						$html .='<div class="message_box"><img class="mssage_box_pic" src="'.$getmemberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div></div>';
					}else{
						$html .='<div class="message_box from_self"><img class="mssage_box_pic" src="'.$memberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div></div>';
					}
				}
			}else{
				$htmltime = '<div class="logtime">'.$v['createtime'].'</div>';
				if($v['type'] == 1){
						if($v['setmid'] == $_SESSION['uid']){
							$html .='<div class="r clearfix"><img class="pic"/><p class="text">'.$v['msg'].'</p></div>';
						}else{
							$html .='<div class="l clearfix"><img class="pic"/><p class="text">'.$v['msg'].'</p></div>';
						}
						$html .= $htmltime;
				}elseif($v['type'] == 3){
					//$v['msg']=tomedia($v['msg']);
					if($v['setmid'] == $_SESSION['uid']){
							$playhtml = '<span ng-show="pagedata.playon == 1" ng-click="pagedata.playon =0" style="display:none;width:'.$v['audioleng'].'rem;text-align:right" class="text kefu-playon"><img src="../core/resource/images/audioplaying.gif"/></span><span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$v['audioleng'].'rem;text-align:right" class="text icon jinyunicon icon-shengbo"></span>';
							$html .='<div onclick="playaudio(\''.$v['msg'].'\');" class="r clearfix"><img class="pic"/><span>'.$v['audiotime'].'\'\'</span>'.$playhtml.'</div>';
					}else{
							if($v['isread'] != 1){
								$unread = '<span class="unread"></span>';
							}else{
								$unread ='';
							}
							$playhtml = '<span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$v['audioleng'].'rem" class="text icon jinyunicon icon-shengbo"></span>';
							$html .='<div onclick="playaudio(\''.$v['msg'].'\',\'\','.$v['id'].');" class="l clearfix"><img class="pic"/>'.$playhtml.'<span>'.$v['audiotime'].'\'\'</span>'.$unread.'</div>';
					}
					$html .= $htmltime;
				}elseif($v['type'] == 4){
					$v['msg']=tomedia($v['msg']);
					if($v['setmid'] == $_SESSION['uid']){
							$html .='<div class="r clearfix"><img class="pic"/><p onclick="followewm(\''.$v['msg'].'\');" class="textimg"><img style="max-width:100%" src="'.$v['msg'].'"/></p></div>';
					}else{
							$html .='<div class="l clearfix"><img class="pic"/><p onclick="followewm(\''.$v['msg'].'\');" class="textimg"><img style="max-width:100%" src="'.$v['msg'].'"/></p></div>';
					}
				}elseif($v['type'] == 7){
					$fileurl=tomedia($v['msg']);
					$pathinfo=pathinfo($v['msg']);
					$fileicon=$pathinfo[extension];
					$filename=pdo_getcolumn('core_attachment',array('uniacid'=>$_SESSION['uniacid'],'attachment'=>$v['msg']),'title');
					$filename=$filename.'.'.$pathinfo[extension];
					if(strpos($fileicon,'xls')){
						$fileicon='icon-exl';
					}elseif(strpos($fileicon,'pd')){
						$fileicon='icon-pdf';
					}elseif(strpos($fileicon,'do')){
						$fileicon='icon-exl';
					}elseif(strpos($fileicon,'zip') || strpos($fileicon,'rar')){
						$fileicon='icon-zip';
					}else{
						$fileicon='icon-copy';
					}
					$filesize=filesize(ROOT_AT.'/'.$v['msg'])/1000;
					$filesize=$filesize.'kb';
					if($v['setmid'] == $_SESSION['uid']){
						$html .='<div class="r clearfix"><img class="pic"/><div class="text"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div>';
					}else{
						$html .='<div class="l clearfix"><img class="pic"/><div class="text"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div>';
					}
				}
			}
		}
	}
	$return['lastid']=$chatlog[0]['id']?:0;
	$return['html']= $html;
	exi($return);
}
if($_RQ['op']=='gethtml'){
	$id=intval($_RQ['id']);
	$chatid=intval($_RQ['chatid']);
	$getmemberlogo=$this->session('getmemberlogo');
	$memberlogo=$this->session('memberlogo');
	$info=pdo_get('jy_kefu_chatlog',array('uniacid'=>$_SESSION['uniacid'],'chatid'=>$chatid,'id'=>$id));
	if($_SESSION['os']=='windows'){
				$htmltime = '<div class="message_box_time">'.$info['createtime'].'</div>';
				if($info['type'] == 1){
					$html .= $htmltime;
						if($info['setmid'] != $_SESSION['uid']){
							$html .='<div class="message_box"><img class="mssage_box_pic" src="'.$getmemberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><p>'.$info['msg'].'</p></div></div></div>';
						}else{
							$html .='<div class="message_box from_self"><img class="mssage_box_pic" src="'.$memberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><p>'.$info['msg'].'</p></div></div></div>';
						}
						
				}elseif($info['type'] == 3){
					$html .= $htmltime;
					//$info['msg']=tomedia($info['msg']);
					if($info['setmid'] != $_SESSION['uid']){
							$playhtml = '<span ng-show="pagedata.playon == 1" ng-click="pagedata.playon =0" style="display:none;width:'.$info['audioleng'].'rem;text-align:right" class="text kefu-playon"><img src="../core/resource/images/audioplaying.gif"/></span><span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$info['audioleng'].'rem;text-align:right" class="text icon jinyunicon icon-shengbo"></span>';
							$html .='<div onclick="playaudio(\''.$info['msg'].'\');" class="r clearfix"><img class="pic"/><span>'.$info['audiotime'].'\'\'</span>'.$playhtml.'</div>';
					}else{
							if($info['isread'] != 1){
								$unread = '<span class="unread"></span>';
							}else{
								$unread ='';
							}
							$playhtml = '<span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$info['audioleng'].'rem" class="text icon jinyunicon icon-shengbo"></span>';
							$html .='<div onclick="playaudio(\''.$info['msg'].'\',\'\','.$info['id'].');" class="l clearfix"><img class="pic"/>'.$playhtml.'<span>'.$info['audiotime'].'\'\'</span>'.$unread.'</div>';
					}
					
				}elseif($info['type'] == 4){
					$info['msg']=tomedia($info['msg']);
						if($info['setmid'] != $_SESSION['uid']){
							$html .='<div class="message_box"><img class="mssage_box_pic" src="'.$getmemberlogo.'" style="display:inline-block;"/><div class="message_content"><p onclick="followewm(\''.$info['msg'].'\');" class="message_content_inner media"><img src="'.$info['msg'].'" style="width:100%;"/></p></div></div>';
						}else{
							$html .='<div class="message_box from_self"><img class="mssage_box_pic" src="'.$memberlogo.'" style="display:inline-block;"/><div class="message_content"><p onclick="followewm(\''.$info['msg'].'\');" class="message_content_inner media"><img src="'.$info['msg'].'" style="width:100%;"/></p></div></div>';
						}
				}elseif($info['type'] == 7){
					$fileurl=tomedia($info['msg']);
					$pathinfo=pathinfo($info['msg']);
					$fileicon=$pathinfo[extension];
					$filename=pdo_getcolumn('core_attachment',array('uniacid'=>$_SESSION['uniacid'],'attachment'=>$info['msg']),'title');
					$filename=$filename.'.'.$pathinfo[extension];
					if(strpos($fileicon,'xls')){
						$fileicon='icon-exl';
					}elseif(strpos($fileicon,'pd')){
						$fileicon='icon-pdf';
					}elseif(strpos($fileicon,'do')){
						$fileicon='icon-exl';
					}elseif(strpos($fileicon,'zip') || strpos($fileicon,'rar')){
						$fileicon='icon-zip';
					}else{
						$fileicon='icon-copy';
					}
					$filesize=filesize(ROOT_AT.'/'.$info['msg'])/1000;
					$filesize=$filesize.'kb';
					if($info['setmid'] != $_SESSION['uid']){
						$html .='<div class="message_box"><img class="mssage_box_pic" src="'.$getmemberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div></div>';
					}else{
						$html .='<div class="message_box from_self"><img class="mssage_box_pic" src="'.$memberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div></div>';
					}
				}
	}else{
		if($info['type'] == 1){
						if($info['setmid'] == $_SESSION['uid']){
							$html .='<div class="r clearfix"><img class="pic"/><p class="text">'.$info['msg'].'</p></div>';
						}else{
							$html .='<div class="l clearfix"><img class="pic"/><p class="text">'.$info['msg'].'</p></div>';
						}
						$html .= $htmltime;
		}elseif($info['type'] == 3){
					//$info['msg']=tomedia($info['msg']);
					if($info['setmid'] == $_SESSION['uid']){
							$playhtml = '<span ng-show="pagedata.playon == 1" ng-click="pagedata.playon =0" style="display:none;width:'.$info['audioleng'].'rem;text-align:right" class="text kefu-playon"><img src="../core/resource/images/audioplaying.gif"/></span><span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$info['audioleng'].'rem;text-align:right" class="text icon jinyunicon icon-shengbo"></span>';
							$html .='<div onclick="playaudio(\''.$info['msg'].'\');" class="r clearfix"><img class="pic"/><span>'.$info['audiotime'].'\'\'</span>'.$playhtml.'</div>';
					}else{
							if($info['isread'] != 1){
								$unread = '<span class="unread"></span>';
							}else{
								$unread ='';
							}
							$playhtml = '<span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$info['audioleng'].'rem" class="text icon jinyunicon icon-shengbo"></span>';
							$html .='<div onclick="playaudio(\''.$info['msg'].'\',\'\','.$info['id'].');" class="l clearfix"><img class="pic"/>'.$playhtml.'<span>'.$info['audiotime'].'\'\'</span>'.$unread.'</div>';
					}
					$html .= $htmltime;
		}elseif($info['type'] == 4){
			$info['msg']=tomedia($info['msg']);
					if($info['setmid'] == $_SESSION['uid']){
							$html .='<div class="r clearfix"><img class="pic"/><p onclick="followewm(\''.$info['msg'].'\');" class="textimg"><img style="max-width:100%" src="'.$info['msg'].'"/></p></div>';
					}else{
							$html .='<div class="l clearfix"><img class="pic"/><p onclick="followewm(\''.$info['msg'].'\');" class="textimg"><img style="max-width:100%" src="'.$info['msg'].'"/></p></div>';
					}
		}elseif($info['type'] == 7){
					$fileurl=tomedia($info['msg']);
					$pathinfo=pathinfo($info['msg']);
					$fileicon=$pathinfo[extension];
					$filename=pdo_getcolumn('core_attachment',array('uniacid'=>$_SESSION['uniacid'],'attachment'=>$info['msg']),'title');
					$filename=$filename.'.'.$pathinfo[extension];
					if(strpos($fileicon,'xls')){
						$fileicon='icon-exl';
					}elseif(strpos($fileicon,'pd')){
						$fileicon='icon-pdf';
					}elseif(strpos($fileicon,'do')){
						$fileicon='icon-exl';
					}elseif(strpos($fileicon,'zip') || strpos($fileicon,'rar')){
						$fileicon='icon-zip';
					}else{
						$fileicon='icon-copy';
					}
					$filesize=filesize(ROOT_AT.'/'.$info['msg']).'kb';
					if($info['setmid'] == $_SESSION['uid']){
						$html .='<div class="r clearfix"><img class="pic"/><div class="text"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div>';
					}else{
						$html .='<div class="l clearfix"><img class="pic"/><div class="text"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div>';
					}
		}
	}
	$return['html']= $html;
	exi($return);
}